#ifndef QGPSPARSER_H
#define QGPSPARSER_H

#include <QObject>
#include <QDateTime>
#include "QNmea0183Package.h"

class QextSerialPort;
class QGpsParser : public QObject
{
    Q_OBJECT
public:
    explicit QGpsParser(QObject *parent = 0);
    ~QGpsParser();

    bool isValid() const;

signals:
    void BeiDouSatellites(const QList<SatelliteInfo> &sats);
    void GPSSatellites(const QList<SatelliteInfo> &sats);

    void positionChanged(double latitude, char nsFlag,
                        double longitude, char ewFlag,
                        float altitude,
                         const QByteArray &rawLatitude,
                         const QByteArray &rawLongitude);
    void utcTimeChanged(const QDateTime &utcTime);
    void speedChanged(float speed, float speedKMH, float dir);

public slots:
    void start(const QString &commName);
    void stop();

private slots:
    void onCommPortDataReady();
    void gotRMCPackage(const QNmea0183Package &pkg);
    void gotGGAPackage(const QNmea0183Package &pkg);
    void gotGSVPackage(const QNmea0183Package &pkg);

private:
    QextSerialPort *_commPort;
    QByteArray _lastRecvedData;

    QList<SatelliteInfo> _bdSatelliteList;
    QList<SatelliteInfo> _gpSatelliteList;
};

#endif // QGPSPARSER_H
